<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<script type="text/javascript" src="<%=basePath%>js/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/xadmin.js"></script>
<link rel="stylesheet" href="<%=basePath%>css/font.css">
<link rel="stylesheet" href="<%=basePath%>css/xadmin.css">
<script src="<%=basePath%>lib/layui/layui.js" charset="utf-8"></script>
<script src="<%=basePath%>js/pc/admin/onlineService.js" charset="utf-8"></script>
<link rel="stylesheet" href="<%=basePath%>lib/layui/css/layui.css"
	media="all">
</head>
<body class="layui-anim layui-anim-up">
	<div class="x-nav">
		<span class="layui-breadcrumb"> <a id="aCalss">权限管理</a> <a>
				<cite>添加导航元素</cite>
		</a>
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			onclick="location.reload()" title="刷新"> <i
			class="layui-icon layui-icon-refresh" style="line-height: 35px;"></i></a>
	</div>

	<div class="layui-container">
		<div class="layui-row" style="margin-top: 25px">
			<fieldset class="layui-elem-field layui-field-title"
				style="margin-top: 30px;">
				<legend>权限管理</legend>
			</fieldset>

			<div id="test1" class="demo-tree-more"></div>
		</div>
	</div>
</body>

<script type="text/javascript">

	layui.use([ 'tree', 'jquery','layer' ], function() {

		var tree = layui.tree;
		var $ = layui.jquery;

		$.post("/tszs/system/loadAuthorit.do", function(res) {

			var data1 = res.data;

			tree.render({
				elem : '#test1',
				data : data1,
				renderContent : true,
				operate : function(obj) {
					var type = obj.type; //得到操作类型：add、edit、del
					var data = obj.data; //得到当前节点的数据
					var elem = obj.elem; //得到当前节点元素
					var id = data.id; //得到节点索引
					if (type === 'add') { //增加节点
						//返回 key 值
						layer.msg("不可用新增权限")
						return 123;
					} else if (type === 'edit') { //修改节点
						
						$.post("/tszs/system/updateAuthority.do",{
							id:data.id,
							label:data.label
						}, function(res) {
							if (res.type == 1) {
								layer.msg(res.msg);
							}
							setTimeout(function(){
								location.reload();
							})
							
						},"json")
						
					} else if (type === 'del') { //删除节点
						layer.msg("不可用新增权限")
					}

				}
			});
			$(".layui-icon-add-1").hide();
			$(".layui-icon-delete").hide();

		}, "json");

	})
</script>

</html>